package com.kaifamiao.www.demo.Do29.pm;

public class Demo {
    public static void main(String[] args) {
        Person person = new Person();
        Student stu = new Student();
        Person person1 = new Student();
        person.age = 18;
       /*
        call方法需要Person类型的数据继承
        */

        call(new Person());
        call(new Student());
        call(new Teacher());
        call(new BoyStudent());
        //重写  同名同参同返回

    }
    public static void call(Person person){

        //父类定义的方法，子类会继承
        person.say();

        //向下转型
        if(person instanceof Student student){
            student.name = "卡卡";
            Student.study();

        }
    }
    public static Person call2(){
       return new Student();
       //return new Teacher();//只能返回一个
       // return new Person();
    }
}
